#' Online zscore
#'
#' @param period rolling window period
#' @param m_period smoothing window period
#' @param z zscore threshold
#' @param r attenuation
#' @param type type of rolling window
#'
#' @return a stateful function
#' @export
#'
new_zscore <- function(period, m_period, z, r, type = c("ro", "ew", "cu"))
{
  type <- match.arg(type)
  switch(type,
         ro = mk_online_func_x("zscore", period, m_period, z, r),
         ew = mk_online_func_x("zscore_ew", period, m_period, z, r),
         cu = mk_online_func_x("zscore_cu", m_period, z, r))
}

#' Online standard zscore
#'
#' @param period rolling window period
#' @param type type of rolling window
#'
#' @return a stateful function
#' @export
#'
new_stdz <- function(period, type = c("ro", "ew", "cu", "vw", "cuvw"))
{
  type <- match.arg(type)
  switch(type,
         ro = mk_online_func_x("stdz", period),
         ew = mk_online_func_x("stdz_ew", period),
         cu = mk_online_func_x("stdz_cu"),
         vw = mk_online_func_xw("stdz_vw", period),
         cuvw = mk_online_func_xw("stdz_cuvw"))
}

#' Online CCI
#'
#' @param period rolling window period
#'
#' @return a stateful function
#' @export
#'
new_cci <- function(period)
{
  mk_online_func_x("cci", period)
}
